const userServer = require("../../service/userService");

const getUserList = async (ctx, next) => {
  let res = await userServer.getUserList();
  ctx.body = {
    code: res.code,
    message: res.message,
    data: res.data,
  };
};

// 全部订单
const gettransList = async (ctx, next) => {
  let res = await userServer.gettrainList();
  ctx.body = {
    code: res.code,
    message: res.message,
    data: res.data,
  };
};

// 删除订单
const deleteList = async (ctx, next) => {
  let res = await userServer.deleteList({ id: ctx.request.body.id });
  ctx.body = {
    code: res.code,
    message: res.message,
  };
};

// 登录
const logindata = async (ctx, next) => {
  console.log("ctx", ctx.query);
  let res = await userServer.loginList({
    username: ctx.query.username,
    password: ctx.query.password,
  });
  ctx.body = {
    code: res.code,
    message: res.message,
  };
};

// 注册
const righrighzhuce = async (ctx, next) => {
  console.log("ctx", ctx.request);
  let res = await userServer.righzhuce({
    username: ctx.request.body.username,
    password: ctx.request.body.password,
    nickname: ctx.request.body.nickname,
    avatar:ctx.request.body.avatar,
    age:ctx.request.body.age,
    phone:ctx.request.body.phone,
    email:ctx.request.body.email,
    
  });    
  ctx.body = {
    code: res.code,
    message: res.message,
  };
};
module.exports = {
  getUserList,
  gettransList,
  deleteList,
  logindata,
  righrighzhuce,
};
     